/*
 * Copyright Bruce Liang (ldcsaa@gmail.com)
 *
 * Version	: JessMA 3.5.1
 * Author	: Bruce Liang
 * Website	: http://www.jessma.org
 * Project	: http://www.oschina.net/p/portal-basic
 * Blog		: http://www.cnblogs.com/ldcsaa
 * WeiBo	: http://weibo.com/u/1402935851
 * QQ Group	: 75375912
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.jessma.util.archive;

import org.apache.tools.ant.taskdefs.Expand;
import org.apache.tools.ant.taskdefs.Untar;
import org.apache.tools.ant.taskdefs.Untar.UntarCompressionMethod;

/** TAR 解档执行器类 */
public class UnTarrer extends UnArchiver
{
	/** TAR 压缩模式 */
	protected static final String[] COMPRESS_MODES = {"none", "gzip", "bzip2"};

	public UnTarrer(String source)
	{
		super(source);
	}
	
	public UnTarrer(String source, String target)
	{
		super(source, target);
	}
	
	/** 获取解压任务对象 */
	@Override
	protected Expand getExpand()
	{
		Untar ut = new Untar();
		ut.setCompression(getCompressionMethod());
		
		return ut;
	}

	private UntarCompressionMethod getCompressionMethod()
	{
		UntarCompressionMethod method = new UntarCompressionMethod();
		method.setValue(getCompressionMode());
		
		return method;
	}
	
	/** 获取 TAR 文件压缩模式 */
	protected String getCompressionMode()
	{
		return COMPRESS_MODES[0];
	}

}
